# Input:    /Data/finalData.RData
# Output:   /Paper/Figures/summ_stats.pdf
# Author:   JB


rm(list = ls())
require(tidyverse)
require(vtable)

# Loading data
load('../Data/finalData.RData')


# Summary stats
pdf('../Paper/Figures/summ_stats.pdf',width = 7,height = 8)
st(utterance_level %>% 
     mutate(Fed = ifelse(grepl('YELLEN',opensecretsID),'Janet Yellen',
                         ifelse(grepl('GREENSPAN',opensecretsID),'Alan Greenspan',
                                ifelse(grepl('BERNANKE',opensecretsID),'Ben Bernanke',
                                       ifelse(grepl('POWELL',opensecretsID),'Jerome Powell',NA)))),
            lagFed = ifelse(grepl('Fed Chair',lag(position)),1,0)) %>%
     select(`Interrupting Utterance` = interruptor,`Interrupted Utterance` = interrupted,
            `Total Utterances` = tot_utterances,`Uttrnc Length (# Chars)` = nchars,
            Year = year,Chamber = chamber,Position = position,`Fed Chair` = Fed,Party = party,Gender = gender,`# Children` = nKids,
            `# Daughters` = nDaughters,`# Sons` = nSons,Age = age,Seniority = seniority,`Vote Share` = votepct,`Ideology (DW-NOM)` = nominate_dim1))
dev.off()
